package com.esri.core.tasks.ags.geoprocessing;

import com.esri.core.internal.util.d;
import com.esri.core.io.EsriServiceException;
import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.Map;
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonToken;
import org.codehaus.jackson.annotate.JsonIgnore;

/* loaded from: classes.dex */
public abstract class GPParameter implements Serializable {
    protected static final String DATATYPE_GPBOOLEAN = "GPBoolean";
    protected static final String DATATYPE_GPDATAFILE = "GPDataFile";
    protected static final String DATATYPE_GPDATE = "GPDate";
    protected static final String DATATYPE_GPDOUBLE = "GPDouble";
    protected static final String DATATYPE_GPFEATURERECORDSETLAYER = "GPFeatureRecordSetLayer";
    protected static final String DATATYPE_GPLINEARUNIT = "GPLinearUnit";
    protected static final String DATATYPE_GPLONG = "GPLong";
    protected static final String DATATYPE_GPMULTIVALUE = "GPMultiValue";
    protected static final String DATATYPE_GPRASTERDATA = "GPRasterData";
    protected static final String DATATYPE_GPRASTERDATALAYER = "GPRasterDataLayer";
    protected static final String DATATYPE_GPRECORDSET = "GPRecordSet";
    protected static final String DATATYPE_GPSTRING = "GPString";
    private static final String DATA_TYPE = "dataType";
    private static final String PARAM_NAME = "paramName";
    private static final String VALUE = "value";
    private static final long serialVersionUID = 1;
    protected String dataType;
    private String paramName;

    public abstract void fromJson(JsonParser jsonParser) throws Exception;

    public abstract String generateValueParams() throws Exception;

    @JsonIgnore
    public String getDataType() {
        return this.dataType;
    }

    @JsonIgnore
    public String getParamName() {
        return this.paramName;
    }

    @JsonIgnore
    public void setParamName(String str) {
        this.paramName = str;
    }

    public Map<String, String> generateRequestParams() {
        LinkedHashMap linkedHashMap = new LinkedHashMap();
        linkedHashMap.put(PARAM_NAME, this.paramName);
        linkedHashMap.put(DATA_TYPE, this.dataType);
        try {
            linkedHashMap.put(VALUE, generateValueParams());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return linkedHashMap;
    }

    public static GPParameter createFromJson(JsonParser jsonParser) throws Exception {
        if (!d.c(jsonParser)) {
            throw new EsriServiceException("Unable to parse the Response for this GPParameter.");
        }
        String str = "#temp#";
        GPParameter gPParameter = null;
        JsonNode jsonNode = null;
        while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
            String currentName = jsonParser.getCurrentName();
            jsonParser.nextToken();
            if (PARAM_NAME.equals(currentName)) {
                if (gPParameter == null) {
                    str = jsonParser.getText();
                } else {
                    gPParameter.paramName = jsonParser.getText();
                }
            } else if (DATA_TYPE.equals(currentName)) {
                if (DATATYPE_GPLONG.equals(jsonParser.getText())) {
                    gPParameter = new GPLong(str);
                } else if (DATATYPE_GPBOOLEAN.equals(jsonParser.getText())) {
                    gPParameter = new GPBoolean(str);
                } else if (DATATYPE_GPDOUBLE.equals(jsonParser.getText())) {
                    gPParameter = new GPDouble(str);
                } else if (DATATYPE_GPSTRING.equals(jsonParser.getText())) {
                    gPParameter = new GPString(str);
                } else if (DATATYPE_GPDATAFILE.equals(jsonParser.getText())) {
                    gPParameter = new GPDataFile(str);
                } else if (DATATYPE_GPDATE.equals(jsonParser.getText())) {
                    gPParameter = new GPDate(str);
                } else if (DATATYPE_GPFEATURERECORDSETLAYER.equals(jsonParser.getText())) {
                    gPParameter = new GPFeatureRecordSetLayer(str);
                } else if (DATATYPE_GPLINEARUNIT.equals(jsonParser.getText())) {
                    gPParameter = new GPLinearUnit(str);
                } else if (DATATYPE_GPRASTERDATA.equals(jsonParser.getText())) {
                    gPParameter = new GPRasterData(str);
                } else if (DATATYPE_GPRASTERDATALAYER.equals(jsonParser.getText())) {
                    gPParameter = new GPRasterDataLayer(str);
                } else if (DATATYPE_GPRECORDSET.equals(jsonParser.getText())) {
                    gPParameter = new GPRecordSet(str);
                }
                if (jsonNode != null) {
                    if (jsonNode.isNull()) {
                        gPParameter = null;
                    } else {
                        gPParameter.fromJson(jsonNode.traverse());
                    }
                    jsonNode = null;
                }
            } else if (!VALUE.equals(currentName)) {
                jsonParser.skipChildren();
            } else if (gPParameter == null) {
                jsonNode = d.b(jsonParser);
            } else if (jsonParser.getCurrentToken() == JsonToken.VALUE_NULL) {
                gPParameter = null;
            } else {
                gPParameter.fromJson(jsonParser);
            }
        }
        return gPParameter;
    }
}
